﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MND.Users
{
    class UserCommandScenario : Scenario
    {
        private UserCommandProcessor masterUCP;
        private string[] functionList;

        public UserCommandScenario(UserCommandProcessor master, string scenarioString, string[] funcList)
        {
            masterUCP = master;
            functionList = funcList;
            Load(scenarioString);
        }

        protected override void SetFunctions()
        {
            object target = null; 
            System.Reflection.MethodBase method = null;
            string methodName = String.Empty;
            foreach (string func in functionList)
            {
                // Defaults:
                target = masterUCP;
                switch (func)
                {
                    case "GetPlayers":
                        methodName = "GetAllUsers";
                        break;
                }
                method = target.GetType().GetMethod(methodName);
                lua.RegisterFunction(func, target, method);
            }

            base.SetFunctions();
        }
    }
}
